package dao;

import vo.Inventory;

import java.util.List;

public class InventoryDaoimpl extends BaseDao implements IInventory{//对库存表操作的具体实现类 继承BaseDao类是为了使用对数据库进行操作的方法,来实现其接口类的操作
    @Override
    public boolean add(Inventory inventory) {
        String sql="insert into inventory values(?,?,?);";
        return update(sql,inventory.getInventory_id(),inventory.getName(),inventory.getCount());
    }

    @Override
    public boolean delete(Inventory inventory) { //通过产品编号来找到要删除的商品
        String sql="delete from inventory where inventory_id=?";
        return update(sql,inventory.getInventory_id());
    }

    @Override
    public boolean modify(Inventory inventory) {//通过商品编号(id)查找到要变的库存信息
        String sql="update custom set inventory_id=?,name=?,count=? where inventory_id=?";
        return update(sql,inventory.getInventory_id(),inventory.getName(),inventory.getCount(),inventory.getInventory_id());
    }

    @Override
    public Inventory getcustombyid(int id) {
        String sql="select*from inventory where inventory_id=?";
        return  getInstance(Inventory.class,sql,id);//按商品编号查询
    }

    @Override
    public List<Inventory> getall() {
        String sql="select*from inventory";
        return getList(Inventory.class,sql);//查询到的所有信息
    }


}
